import java.util.ArrayList;

public class palindrome_linked_list {
    public boolean isPalindrome(ListNode head) {
        ArrayList<Integer> vals=new ArrayList();
        ListNode cur=head;
        while(cur!=null){
            vals.add(cur.val);
            cur=cur.next;
        }
        int front=0;
        int back=vals.size()-1;
        while(front<back){
            if(!vals.get(front).equals(vals.get(back))){
                return  false;
            }
            front++;
            back--;
        }
        return true;
    }
}
